﻿using HiSport.Application.TestManagement.Test1Service;
using HiSport.Core.Entity.HiSportWebEntity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HiSport.Application.TestManagement.Test2Service
{
    public class Test2Service : ITest2Service, ITransient
    {
        private readonly ITest1Service _test1Service;
        private readonly SqlSugarRepository<Test> _testRep;

        public Test2Service(ITest1Service test1Service, SqlSugarRepository<Test> testRep)
        {
            _test1Service = test1Service;
            _testRep = testRep;
        }

        public async Task<string> Test02(string str)
        {
            var result = await _test1Service.Test01(str);

            return result + "002";
        }

        public async Task<SqlSugarPagedList<Test>> Test03(BasePageInput input)
        {
            return await _testRep.AsQueryable()
           .ToPagedListAsync(input.Page, input.PageSize);
        }

        public async Task<bool> Test04()
        {
            return await _testRep.InsertAsync(new Test()
            {
                Name = Guid.NewGuid().ToString(),
            });
        }
    }
}
